package com.demo;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-10-27
 * Time: 22:43
 */
public class BeanLifeController implements BeanNameAware {
    //属性注入在初始化之前
    @Override
    public void setBeanName(String s) {
        System.out.println("执行了 SetBeanName 方法: " + s);
    }

    public void init() {
        System.out.println("执行了 Init 方法");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("执行了 postConstruct 方法");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("执行了 preDestroy 方法");
    }
}
